#pragma once
#include <vector>

using namespace std;

namespace rotate
{
	class Solution {
	public:
		void rotate(vector<int>& nums, int k) {
			int tmp, left, right;
			int size = nums.size();
			k = k % size;
			left = 0;
			right = size - 1;
			while (left < right)
			{
				tmp = nums[left];
				nums[left] = nums[right];
				nums[right] = tmp;
				left++;
				right--;
			}

			left = 0;
			right = k - 1;
			while (left < right)
			{
				tmp = nums[left];
				nums[left] = nums[right];
				nums[right] = tmp;
				left++;
				right--;
			}

			left = k;
			right = size - 1;
			while (left < right)
			{
				tmp = nums[left];
				nums[left] = nums[right];
				nums[right] = tmp;
				left++;
				right--;
			}
		}
	};

}

